﻿//using System;
//using Blockey.GameObjects3D;
//using BlockeyEssentials;
//using BlockeyEssentials.Drawing;
//using BlockeyEssentials.ScreenSystem;
//using Microsoft.Xna.Framework;
//using Microsoft.Xna.Framework.Graphics;
//using Microsoft.Xna.Framework.Net;

//namespace Blockey.GameplayScreens
//{
//    public class TestWorldScreen3D : MatchScreen3D
//    {
//        public TestWorldScreen3D(ScreenManager oManager)
//            : base(oManager)
//        {
//        }

//        #region Methods

//        public override void Update()
//        {
//            base.Update();

//        }

//        protected override void DrawGameTypeElements(SpriteBatch oSB)
//        {

//        }

//        public override void ActionWhenFullyAdded()
//        {
//            if (Networking.IsRunning)
//            {
//                HookEvents();
//            }
//        }

//        protected override void SendClientToHost()
//        {
//            base.SendClientToHost();
//        }

//        protected override void SendHostToClients()
//        {
//            base.SendHostToClients();
//        }

//        protected override void ClientReceiveFromHost()
//        {
//            foreach (var oLocal in Networking.Session.LocalGamers)
//            {
//                if (oLocal.IsHost == false)
//                {
//                    while (oLocal.IsDataAvailable)
//                    {
//                        NetworkGamer oHost;
//                        oLocal.ReceiveData(Networking.Reader, out oHost);

//                        foreach (var oGamer in Networking.Session.AllGamers)
//                        {
//                            var oPerson = oGamer.Tag as Person3D;
//                            var x = (float)Networking.Reader.ReadInt16() * 0.01f;
//                            var y = (float)Networking.Reader.ReadInt16() * 0.01f;
//                            oPerson.PositionDestination = new Vector3(x, y, 0);
//                            oPerson.PrevPosition = oPerson.Position;

//                            var oRotation = oPerson.Rotation;
//                            oRotation.Z = MathHelper.ToRadians(Networking.Reader.ReadInt16());
//                            oPerson.Rotation = oRotation;

//                            var oCondition = (ConditionName)Networking.Reader.ReadByte();
//                            if (oPerson.Condition.Name != oCondition)
//                            {
//                                oPerson.Condition.ChangeTypeForClient(oCondition);
//                                oPerson.StartCondition(false);
//                            }
//                        }
//                    }
//                }
//            }
//        }

//        protected override void HandleCollision(Moveable3D oMoveA, Moveable3D oMoveB)
//        {
//            base.HandleCollision(oMoveA, oMoveB);
//        }

//        #endregion

//        #region Network Session Events

//        private static void HookEvents()
//        {
//            if (Networking.Session.IsHost)
//            {
//                Networking.Session.AllowJoinInProgress = true;
//                Networking.Session.AllowHostMigration = true;
//            }
//            Networking.Session.GamerJoined += new EventHandler<GamerJoinedEventArgs>(session_GamerJoined);
//            Networking.Session.GamerLeft += new EventHandler<GamerLeftEventArgs>(session_GamerLeft);
//            Networking.Session.GameStarted += new EventHandler<GameStartedEventArgs>(session_GameStarted);
//            Networking.Session.HostChanged += new EventHandler<HostChangedEventArgs>(session_HostChanged);
//            Networking.Session.GameEnded += new EventHandler<GameEndedEventArgs>(session_GameEnded);
//        }

//        // Fired when the game ends
//        static void session_GameEnded(object sender, GameEndedEventArgs e)
//        {

//        }

//        // Triggered when the host is changed
//        static void session_HostChanged(object sender, HostChangedEventArgs e)
//        {
//            var oPersonOld = e.OldHost.Tag as Person3D;
//            var oPersonNew = e.NewHost.Tag as Person3D;

//            if (oPersonOld != null && oPersonNew != null)
//            {

//            }
//        }

//        // Triggered when the game starts 
//        static void session_GameStarted(object sender, GameStartedEventArgs e)
//        {

//        }

//        // Triggered when a gamer leaves the game
//        static void session_GamerLeft(object sender, GamerLeftEventArgs e)
//        {
//            var oPerson = e.Gamer.Tag as Person3D;

//            if (oPerson != null)
//            {
//                RemoveObject(oPerson);
//                e.Gamer.Tag = null;
//            }
//        }

//        // Triggered when a gamer joins the game
//        static void session_GamerJoined(object sender, GamerJoinedEventArgs e)
//        {
//            var oGamer = e.Gamer;
//            var oPerson = new Skater(All.CurrentScreenManager.Game, ControllingPlayer.AI, Alliance.Home);

//            AddObject(oPerson);
//            e.Gamer.Tag = oPerson;
//        }

//        #endregion

//    }
//}
